<?php

namespace App\Library\Logic;

use App\Models\PaymentModel;
use Illuminate\Database\Eloquent\Model;

class PaymentLogic extends PaymentModel
{
    /**
     * plug
     * @param Model $order
     * @param Model $product
     * @param Model $amount
     * @param Model $paymentRelated
     * @param int $paymentMethodId
     * @return void
     */
    public static function plug(Model $order, Model $product, Model $amount, Model $paymentRelated, int $paymentMethodId): void
    {
        self::insertForModel([
            'objectType' => $order->getTable(),
            'objectId' => $order->order_id,
            'paymentRelatedId' => $paymentRelated->id,
            'amount' => $amount->amount,
            'paymentMethodId' => $paymentMethodId,
            'initiatorUserId' => USERID,
            'receiveUserId' => $product->user_id,
            'initiatorUserAccountId' => '',
            'receiveUserAccountId' => 1,
            'outTradeNo' => $amount->serial_number,
            'result' => $amount,
            'find' => $amount,
            'payAt' => now(),
        ]);
    }
}
